<?php
/**
 * Created by PhpStorm.
 * User: xiaomeng
 * Date: 17-7-12
 * Time: 下午3:28
 */
namespace mphp\Core;
use mphp\QueryBuilder\Mongo;
use mphp\Connections\RedisPool;

class syncDb
{
    private static $instance=null;
    private static $_redis;
    private static $_mongo;

    private function __construct(){
    }

    /**
     * @return Db
     */
    public static function getInstance(){
        if(empty(self::$instance)){
            self::$instance = new self();
        }
        return self::$instance;
    }



    /**
     * @return RedisPool
     */
    public static function redis(){
        if(!isset(self::$_redis)){
            self::$_redis = RedisPool::getDb();
        }
        return self::$_redis;
    }

    /**
     * @param $collection
     * @return Mongo
     */
    public static function collection($collection=''){
        if(!isset(self::$_mongo[$collection])){
            self::$_mongo[$collection] = Mongo::getInstance($collection);
        }
        return self::$_mongo[$collection];
    }
}